package com.sgb.jicai.entity;

import android.text.TextUtils;
import android.util.Log;

import java.util.List;

/**
 * 供方发起--立即参与页面实体类
 */
public class FactoryParticipationEntity {
    //单位
    private String unitName;
    //数量
    private String num;
    //业务编号
    private String detailNo;
    //商家集采no
    private String saleNo;
    //提货时间
    private String pickTime;
    //截止时间
    private String endTime;
    //最低采购量
    private String lowBuy;
    private String originalPrice;
    //规格参数
    private List<AttrsEntity> attrs;
    //报价规则
    private List<PriceRolesEntity> priceRules;

    public String getOriginalPrice() {
        if (!TextUtils.isEmpty(originalPrice)&&!originalPrice.equals("0")){
            return originalPrice;
        }else {
            return "";
        }
    }

    public void setOriginalPrice(String originalPrice) {
        this.originalPrice = originalPrice;
    }

    public String getUnitName() {
        return unitName;
    }

    public void setUnitName(String unitName) {
        this.unitName = unitName;
    }

    public String getNum() {
        return num;
    }

    public void setNum(String num) {
        this.num = num;
    }

    public String getDetailNo() {
        return detailNo;
    }

    public void setDetailNo(String detailNo) {
        this.detailNo = detailNo;
    }

    public String getSaleNo() {
        return saleNo;
    }

    public void setSaleNo(String saleNo) {
        this.saleNo = saleNo;
    }

    public String getPickTime() {
        return pickTime;
    }

    public void setPickTime(String pickTime) {
        this.pickTime = pickTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public String getLowBuy() {
        return lowBuy;
    }

    public void setLowBuy(String lowBuy) {
        this.lowBuy = lowBuy;
    }

    public String getAttrs() {
        if (null == attrs || attrs.size() == 0) {
            return "";
        }
        StringBuffer str = new StringBuffer();
        for (int i = 0; i < attrs.size(); i++) {
            str.append(attrs.get(i).getName()).append(" :  ").append(attrs.get(i).getValue()).append("    ");
        }
        return new String(str);
    }


    public void setAttrs(List<AttrsEntity> attrs) {
        this.attrs = attrs;
    }

    public List<PriceRolesEntity> getPriceRules() {
        return priceRules;
    }

    public void setPriceRules(List<PriceRolesEntity> priceRules) {
        this.priceRules = priceRules;
    }

    /**
     * 采购清单下价格规则列表
     */
    public class PriceRolesEntity {
        private String intervalStartValue;
        private String intervalEndValue;
        private String price;
        private String detailNo;
        private String sort;
        private String saleNo;
        private String priceRole;
        /**
         * 价格预警 1 大于 2 等于 3 小于
         */
        private int priceWarning;

        public String getIntervalStartValue() {
            return intervalStartValue;
        }

        public void setIntervalStartValue(String intervalStartValue) {
            this.intervalStartValue = intervalStartValue;
        }

        public String getIntervalEndValue() {
            return intervalEndValue;
        }

        public void setIntervalEndValue(String intervalEndValue) {
            this.intervalEndValue = intervalEndValue;
        }

        public String getPrice() {
            return price;
        }

        public void setPrice(String price) {
            this.price = price;
        }

        public String getDetailNo() {
            return detailNo;
        }

        public void setDetailNo(String detailNo) {
            this.detailNo = detailNo;
        }

        public String getSort() {
            return sort;
        }

        public void setSort(String sort) {
            this.sort = sort;
        }

        public String getSaleNo() {
            return saleNo;
        }

        public void setSaleNo(String saleNo) {
            this.saleNo = saleNo;
        }

        public String getPriceRole() {
            String start = "";
            String end = "";
            String unitName = "";
            String price = "";
            try {
                start = getIntervalStartValue().isEmpty() ? "  " : getIntervalStartValue();
                end = getIntervalEndValue().isEmpty() ? "  " : getIntervalEndValue();
                price = getPrice().isEmpty() ? "  " : getPrice();
                unitName = getUnitName().isEmpty() ? "  " : getUnitName();//外层获取异常，已使用分开TextView
            } catch (Exception e) {
                Log.e("getPriceRole", e.toString());
            }
            return start + " - " + end + unitName + "  " + price + "元";
        }

        public void setPriceRole(String priceRole) {
            this.priceRole = priceRole;
        }

        public int getPriceWarning() {
            return priceWarning;
        }

        public void setPriceWarning(int priceWarning) {
            this.priceWarning = priceWarning;
        }
    }

    /**
     * 规格材质 Attrs
     */
    public class AttrsEntity {
        private String name;
        private String value;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }
    }


}
